package com.itheima.service.impl;

import com.itheima.mapper.StudentMapper;
import com.itheima.pojo.Student;
import com.itheima.pojo.StudentQueryParam;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public List<Student> list(StudentQueryParam student) {
        List<Student> students = studentMapper.selectList(null);
        return students;
    }

    @Override
    public void save(Student student) {
        studentMapper.insert(student);

    }

    @Override
    public Student getById(Integer id) {
        Student student = studentMapper.selectById(id);
        return student;
    }

    @Override
    public void update(Student student) {
        studentMapper.updateById(student);

    }

    @Override
    public void delete(List<Integer> ids) {
        studentMapper.deleteBatchIds(ids);

    }

    @Override
    public void violation(Integer id, Integer score) {
        studentMapper.updateScore(id, score);
    }
}
